1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : ressourcen/classes/filemanager/class.folder.inc.php
5 : - Modulgruppe: File Manager
6 : - Beschreibung: Klasse "Folder"
7 : - Version: 0.4, 08.01.08
8 : - Autor(en): Tobias Wild <tobias.wild@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 :
24 : if (!defined("PATH_TO_ROOT")) {
25 : define("PATH_TO_ROOT", "../../../");
26 : }
27 :
28 : require_once (PATH_TO_ROOT."ressourcen/classes/class.ressourcendb.inc.php");
29 : require_once (PATH_TO_ROOT."ressourcen/classes/class.filemanger.inc.php");
30 :
31 : abstract class Resource {
32 : protected $fileID;
33 : protected $courseID;
34 : protected $userID;
35 : protected $link;
36 : protected $name;
37 : protected $visibleType;
38 : protected $createTime;
39 : protected $description;
40 :
41 : protected $fileManager = null;
42 :
43 : public function getID() {
44 0 : return $this->fileID;
45 : }
46 :
47 : public function setFileManager( $fileManager ) {
48 0 : $this->fileManager = $fileManager;
49 0 : }
50 :
51 : public function getFileManager() {
52 0 : return $this->fileManager;
53 : }
54 :
55 : public function setCreateTime( $createTime ) {
56 0 : $this->createTime = $createTime;
57 0 : }
58 :
59 : /**
60 : * Setter for description
61 : *
62 : * @param String $description Description
63 : */
64 : public function setDescription ( $description ) {
65 0 : $this->description = $description ;
66 0 : }
67 :
68 : /**
69 : * Getter for description
70 : *
71 : * @return String Description
72 : */
73 : public function getDescription() {
74 0 : return $this->description;
75 : }
76 :
77 : public function setFileID ( $fileID ) {
78 0 : $this->fileID = $fileID;
79 0 : }
80 :
81 : public function setCourseID ( $courseID ) {
82 0 : $this->courseID = $courseID;
83 0 : }
84 :
85 : /**
86 : * Getter for course id.
87 : *
88 : * @return Integer Course id
89 : */
90 : public function getCourseID () {
91 0 : return $this->courseID;
92 : }
93 :
94 : public function setUserID ($userID) {
95 0 : $this->userID = $userID;
96 0 : }
97 :
98 : public function setLink ($link) {
99 0 : $this->link = $link;
100 0 : }
101 :
102 : public function setVisibleType ($visibleType) {
103 0 : $this->visibleType = $visibleType;
104 0 : }
105 :
106 : public function setName ($name) {
107 0 : $this->name = $name;
108 0 : }
109 :
110 : public function getName() {
111 0 : return $this->name;
112 : }
113 :
114 : public function getLink() {
115 0 : return $this->link;
116 : }
117 :
118 : protected function getRessourceVisibilityHTML() {
119 0 : $visibleSelect = "<div class='res_file-extra'>"."Sichtbarkeit ändern: <br/>";
120 0 : $activeFolder = $this->fileManager->getActiveFolder();
121 0 : $action = $this->fileManager->getAction();
122 0 : $actionID = $this->fileManager->getActionID();
123 0 : if (isset($_GET['mode'])) {
124 0 : $mode = $_GET['mode'];
125 0 : $modeOne = "<a href='".$this->createLink(
126 0 : 0, array(
127 0 : 'activeFolder' => $activeFolder, "action" => "setVisibilityDocentsOnly",
128 0 : 'actionID' => $actionID, 'mode' => $mode
129 0 : )
130 0 : ) ."'>Dozenten</a> ";
131 0 : $modeTwo = "<a href='".$this->createLink(
132 0 : 0, array(
133 0 : 'activeFolder' => $activeFolder, "action" => "setVisibilityNoStudents",
134 0 : 'actionID' => $actionID, 'mode' => $mode
135 0 : )
136 0 : ) ."'>Dozenten und Tutoren</a>
137 0 : ";
138 0 : $modeThree = "<a href='".$this->createLink(
139 0 : 0, array(
140 0 : 'activeFolder' => $activeFolder, "action" => "setVisibilityAll",
141 0 : 'actionID' => $actionID, 'mode' => $mode
142 0 : )
143 0 : ) ."'>Alle</a> ";
144 0 : } else {
145 0 : $mode = 1;
146 0 : $modeOne = "<a href='".$this->createLink(
147 0 : 0, array(
148 0 : 'activeFolder' => $activeFolder, "action" => "setVisibilityDocentsOnly",
149 0 : 'actionID' => $actionID, 'mode' => $mode
150 0 : )
151 0 : ) ."'>Dozenten</a> ";
152 0 : $modeTwo = "<a href='".$this->createLink(
153 0 : 0, array(
154 0 : 'activeFolder' => $activeFolder, "action" => "setVisibilityNoStudents",
155 0 : 'actionID' => $actionID, 'mode' => $mode
156 0 : )
157 0 : ) ."'>Dozenten und Tutoren</a> ";
158 0 : $modeThree = "<a href='".$this->createLink(
159 0 : 0, array(
160 0 : 'activeFolder' => $activeFolder, "action" => "setVisibilityAll",
161 0 : 'actionID' => $actionID, 'mode' => $mode
162 0 : )
163 0 : ) ."'>Alle</a> ";
164 : }
165 0 : if ($mode == 1) {
166 0 : switch ($this->visibleType) {
167 0 : case 3: //nur für Dozenten
168 0 : $visibleSelect.= "<b>Dozenten</b> ".$modeTwo.$modeThree;
169 0 : break;
170 :
171 0 : case 2: // Dozenten und Tutoren
172 0 : $visibleSelect.= $modeOne."<b>Dozenten und Tutoren</b> ".$modeThree;
173 0 : break;
174 :
175 0 : case 1: // Alle
176 0 : $visibleSelect.= $modeOne.$modeTwo."<b>Alle</b> ";
177 0 : break;
178 0 : }
179 0 : } else $visibleSelect.= $modeOne.$modeTwo.$modeThree;
180 0 : $visibleSelect.= "<a href='".$this->createLink(0, array("activeFolder" => $activeFolder)) .
181 0 : "'>Abbrechen</a> ".Utilities::helpCode(700) ."</div>";
182 0 : return $visibleSelect;
183 : }
184 :
185 :
186 : /**
187 : * Erstellt einen Link mit GET Variablen
188 : *
189 : * @param bool [$oldOnes] Gibt an ob bisher existierende GET Variablen mit in den Link eingebaut werden.
190 : * @param array [$vars] Ein Array (Aufbau wie $_GET) mit den Variabeln und WErten die in den Link eingebaut werden
191 : * @param string [$link] Falls nicht PHP_SELF das Ziel ist muss hier der Dateiname angegeben werden.
192 : * @return string Zusammengesetzter Link
193 : * @access private
194 : */
195 : public static function createLink($oldOnes = true, $vars = '', $link = '') {
196 0 : if ($link == "") $link = PATH_TO_ROOT.SCRIPT_NAME;
197 0 : if (!is_array($vars)) $vars = $_GET;
198 0 : elseif (count($_GET) > 0 && $oldOnes) $vars = array_merge($_GET, $vars);
199 0 : foreach($vars as $getVarName => $getVarValue) {
200 0 : if (trim($getVarValue) != "" && isset($getVarValue))
201 0 : $getVars[] = urlencode($getVarName) ."=".urlencode($getVarValue);
202 0 : }
203 0 : return $link."?".implode($getVars, "&");
204 : }
205 : }
|